package pl.ptemich.eav.structures;

import java.util.List;

import org.newdawn.slick.Graphics;

import pl.ptemich.tankwars.objects.Point;

/**
 * 
 * http://en.wikipedia.org/wiki/Quadtree
 * http://blog.notdot.net/2009/11/Damn-Cool-Algorithms-Spatial-indexing-with-Quadtrees-and-Hilbert-Curves
 * 
 * @author Brutusek
 *
 * @param <C>
 */
public class QuadTree<C> {

  private BoundingBox box;
  
  private List<C> elements;
  
  private QuadTree<C> northWest;
  private QuadTree<C> northEast;
  private QuadTree<C> southWest;
  private QuadTree<C> southEast;
  
  public void draw(Graphics graphics) {
    if (northWest != null) {
      northWest.draw(graphics);
    }
    if (northEast != null) {
      northEast.draw(graphics);
    }
    if (southWest != null) {
      southWest.draw(graphics);
    }
    if (southEast != null) {
      southEast.draw(graphics);
    }
    graphics.drawRect(box.getPosX(), box.getPosY(), box.getRowLength(), box.getRowLength());
  }
  
  public QuadTree(BoundingBox box) {
    this.box = box;
  }
  
  public void insert(Point point) {
    
  }
  
  //  create four children which fully divide this quad into four quads of equal area
  public void subdivide() {
    
  } 
  
  public void queryRange(BoundingBox range) {
    
  }  
  
  
}
